/**
 * Class: FireworksCannon
 *
 * Purpose: 
 *
 * Created: Jan 26, 2010 @ 10:03:55 PM
 * @author Ken Scott
 */
package org.openfantasia.ps.fireworks;

import org.openfantasia.ps.actor.GlowingDot;
import org.openfantasia.ps.particle.Particle;
import org.openfantasia.ps.particle.ParticleSource;
import org.openfantasia.ps.shape.Dot;
import org.openfantasia.ui.PColor;
import org.openfantasia.ui.PFrame;
import org.openfantasia.util.math.DPoint3;

public class FireworksCannon extends ParticleSource {

	public FireworksCannon(PFrame frame, double height) {
		direction = new DPoint3(0, height, 0);
		setFillColor(PColor.RED);
		setActor(new GlowingDot(frame, 2f));

		rate = 1;

		addParticleFactory(new ExploderFactory(frame, 100, 10, 3.0, new Dot(frame, 4)));
	}


	public Particle prepParticle(Particle particle) {
		particle.setPosition(position);
		particle.setVelocity(direction.copy().add(new DPoint3().randomize(30)));
		return particle;
	}

}
